package cn.tutu.blockchain.integral.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.tutu.blockchain.common.Page;
import cn.tutu.blockchain.integral.dao.IntegralRecordDao;
import cn.tutu.blockchain.integral.entity.IntegralRecord;
import cn.tutu.blockchain.integral.service.IntegralRecordService;

@Service
@Transactional
public class IntegralRecordServiceImpl implements IntegralRecordService {

	@Autowired
	private IntegralRecordDao integralRecordDao;

	@Override
	public PageInfo<IntegralRecord> getByUserId(String userId, Page page) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		List<IntegralRecord> list = integralRecordDao.findByUserId(userId);
		PageInfo<IntegralRecord> pageInfo = new PageInfo<IntegralRecord>(list);
		return pageInfo;
	}

	@Override
	public void create(IntegralRecord integralRecord) {
		integralRecordDao.insert(integralRecord);

	}

}
